import { createRouter, createWebHistory } from "vue-router";
import Cookies from "js-cookie";
import basicRouting from "./modules/baseRoute.js";

let routes = basicRouting;




const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes,
});

// router.beforeEach((to, from, next) => {
//   if (Cookies.get("admin-token")) {
//     // 生成一个当前用户可以访问的路由表
//     // router.addRoutes() 动态添加这个可以访问的路由表
//     // next()
//     next();
//   } else {
//     // if (whiteList.indexOf(to.path) != -1) {
//     //   next();
//     // } else {
//     if (to.path === "/login") {
//       next();
//     } else {
//       next("/login");
//     }
//   }
// });

router.afterEach((to, from) => {
  document.title = to.meta.title;
});

export default router;
